// JavaScript Document
// 全选或全不选
// @param string object For example："table" 、".table"
function allOrNotAll(object)
{
	$(object).on("click","[all]",function(e)
	{
		e.stopPropagation();
		var isAll = $(this)[0].checked;
		if(isAll)
		{
			$(object).find("[single]").each(function(index, el) {
				$(this)[0].checked = true;
			});
		}
		else
		{
			$(object).find("[single]").each(function(index, el) {
				$(this)[0].checked = false;
			});
		}
	});
	$(object).on("click","[single]",function(e)
	{
		e.stopPropagation();
		var singleLength = $(object).find("[single]").length;
		var checkedLength = $(object).find("[single]:checked").length;
		singleLength == checkedLength ? $(object).find("[all]")[0].checked = true : $(object).find("[all]")[0].checked = false;
	});
}
//php数组转成js数组
function phpArrayToJsArray(phpArray)
{
	var tmp = phpArray;
	tmp = tmp.split(",");
	return tmp;
}
// 统计数组
function countByDate(date,array)
{
	var tmp=[];
	for (var j = 0; j < date.length; j++) {
		tmp[j]=0;
	}
	for (var i = 0; i < array.length; i++) {
		for (var j = 0; j < date.length; j++) {
			array[i] == date[j] ? ++tmp[j]:null;
		}
	}
	return tmp;
}
// 去除数组重复项
function distinc(array)
{
	var tmp = [];
	var a = 0;
	var b = 0;
	for (var i = 0; i < array.length; i++)
	{
		b=0;
		if(tmp.length == 0)
		{
			tmp[a] = array[i];
		}
		else
		{
			for (var j = 0; j < tmp.length; j++) 
			{
				if(tmp[j] == array[i])
				{
					++b;
				}
			}
			if(b == 0)
			{
				++a;
				tmp[a] = array[i];
			}
		}

	}
	return tmp;
}